import 'package:flutter/widgets.dart';
import 'package:flutter_chubao/tools/app_image_load.dart';
import 'package:flutter_chubao/tools/app_colors.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class AppWidgetBg extends StatelessWidget {
  final Color? color;
  final Widget? child;
  final String? assetImage;
  final EdgeInsets? padding;
  final BoxFit fit;
  AppWidgetBg(
      {this.color,
      this.child,
      this.assetImage,
      this.padding,
      this.fit = BoxFit.fitWidth});
  @override
  Widget build(BuildContext context) {
    // Colors.grey
    return GestureDetector(
      onTap: () {
        FocusScope.of(context).requestFocus(FocusNode());
      },
      child: Container(
        width: 1.sw,
        height: 1.sh,
        padding: padding,
        decoration: BoxDecoration(
            color: color ?? kColorAssistG2,
            image: assetImage != null
                ? DecorationImage(
                    fit: fit,
                    alignment: Alignment.topCenter,
                    image: AppImage.getAssetImage(assetImage!))
                : null),
        child: child,
      ),
    );
  }
}
